package com.ruoyi.utils;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.domain.entity.SysDictType;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.mapper.SysDictDataMapper;
import com.ruoyi.system.mapper.SysDictTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping("/h5/dict")
public class DictUtilsH5 extends BaseController {

    @Autowired
    private SysDictTypeMapper sysDictTypeMapper;

    @Autowired
    private SysDictDataMapper sysDictDataMapper;

    /**
     * 获取字典类型
     */
    @GetMapping("/getDictData/{type}")
    public TableDataInfo dictDataList(@PathVariable("type") String type){
        List<SysDictData> sysDictData = sysDictDataMapper.selectDictDataByType(type);
        return getDataTable(sysDictData);
    }

    /**
     * 获取“随手拍”字典类型
     * @return
     */
    @GetMapping("/getType")
    public TableDataInfo Typelist()
    {
        List<SysDictData> sysDictData = sysDictDataMapper.selectDictDataByType(DictStrUtils.CLAP_TYPE);
        return getDataTable(sysDictData);
    }

}
